#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e4+5;

struct abgk{
    int a,b,g,k;
};

void solve(){
    int n;
    cin>>n;
    vector<abgk> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i].a>>arr[i].b>>arr[i].g>>arr[i].k;
    }
    int x,y;
    cin>>x>>y;
    for(int i=n-1;i>=0;i--){
        if(x>=arr[i].a&&x<=arr[i].a+arr[i].g&&y>=arr[i].b&&y<=arr[i].b+arr[i].k){
            cout<<i+1<<endl;
            return;
        }
    }
    cout<<"-1"<<endl;
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}